/**
* This file is part of OntoApplications (project linked with OntoCompoFramework)
*
* Copyright (C) 2011 -  Christian Brel
*
* @author   Main    Christian Brel
**/
package applications.insurancecard.ui.lib;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComponent;

import org.objectweb.fractal.fraclet.annotations.Component;
import org.objectweb.fractal.fraclet.annotations.Interface;
import org.objectweb.fractal.fraclet.annotations.Requires;
import org.objectweb.fractal.fraclet.types.Cardinality;

@Component(provides = {@Interface(name = "jButtonItf", signature = org.objectweb.fractal.swing.JButtonItf.class), @Interface(name = "jButtonAttributes", signature = org.objectweb.fractal.swing.JButtonAttributes.class), @Interface(name = "uicontainerservice", signature = ontocompo.api.UIContainerService.class), @Interface(name = "ontocompointrospection", signature = ontocompo.api.OntoCompoIntrospection.class)})
public class ValidateInsuranceIdButton extends JButton implements org.objectweb.fractal.swing.JButtonItf, org.objectweb.fractal.swing.JButtonAttributes, ontocompo.api.UIContainerService, ontocompo.api.OntoCompoIntrospection {

	private String uid;
	private org.objectweb.fractal.api.Component c;
	
	@Requires(name = "jTextFieldItf")
	private org.objectweb.fractal.swing.JTextFieldItf jTextFieldItf;
	
	@Requires(name = "insurancecardservice")
	private applications.insurancecard.fc.api.InsuranceCardService insurancecardservice;
	
	public ValidateInsuranceIdButton() {
		super ("Super Boutton");
		this.uid = "applications.insurancecard.ui.lib.ValidateInsuranceIdButton";
		System.out.println(this.toString() + " created");
		//this.init();
	}
	
	public void init() {
		this.setText("show insurance information");
		this.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				showInsuranceButtonAction();
			}
			
		});
	}
	
	private void showInsuranceButtonAction() {
		this.insurancecardservice.setId(Integer.parseInt((String) this.jTextFieldItf.getText()));
		//InsuranceInformation ii = this.insurancecardservice.getInsuranceInfo(Integer.parseInt((String) this.actionValueService.getActionValue()));
		//RefreshObservable.getInstance().refresh(new RefreshObject("InsuranceCard", ii));
	}
	
//	@Override
	public JComponent getComponentItSelf() {
		// TODO Auto-generated method stub
		return this;
	}

	@Override
	public String getUid() {
		// TODO Auto-generated method stub
		return this.uid;
	}

	@Override
	public void setUid(String uid) {
		// TODO Auto-generated method stub
		this.uid = uid;
	}
	
	public String toString() {
		return "ValidateInsuranceIdButton";
	}

	@Override
	public org.objectweb.fractal.api.Component getFractalComponent() {
		// TODO Auto-generated method stub
		return this.c;
	}

	@Override
	public void setFractalComponent(org.objectweb.fractal.api.Component c) {
		// TODO Auto-generated method stub
		this.c = c;
	}

	@Override
	public void update(Object o) {
		// TODO Auto-generated method stub
		
	}

}
